#ifndef xpack_lang_cxx_insert
#define xpack_lang_cxx_insert
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::lang_cxx::inc
#include"define/base_type.hpp"
#include"lang/cxx.hpp"
#include"macro/xunlikely.hpp"
#include"memop/copy.hpp"
#pragma pop_macro("xuser")

namespace mixc::lang_cxx{
    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::insert(ixx index, item_cref_t value, xalloc_t const & alloc) const {
        return xthe.insert(index, the_t(& value, 1), alloc);
    }

    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::insert(ixx index, the_cref_t value, xalloc_t const & alloc) const {
        xindex_rollback(xthe->length, index, + 1);
        auto target_length      = xthe->length + value->length;
        auto result             = the_t{};
        auto allocx             = the_t::helper::stream_helper(alloc, xmodify(result.m_ptr), xmodify(result.m_length));
        auto stream             = allocx(target_length);

        if (stream != nullptr){
            stream.output(m_ptr, uxx(index));
            stream.output(value.m_ptr, value.m_length);
            stream.output(m_ptr + index, m_length - index);
        }

        if constexpr (inc::is_same<ret_t, the_t>){
            return result;
        }
    }
}

#endif
